package com.jlcindia.spring;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Lab01 {
	public static void main(String[] args) {
		/*
		 * Without IOC
		 * 
		 * A aobj=new A();
		 * aobj.setA(99);
		 * aobj.setMsg("Hello Guys");
		 * System.out.println("******************");
		 * B bobj=new B(88, "Hai Guys");
		 * System.out.println("******************");
		 * Hello hello=new Hello(bobj);
		 * System.out.println("******************");
		 * hello.setAobj(aobj);
		 * System.out.println("******************");
		 * hello.show();
		 *
		 */
		
		ApplicationContext ctx=new ClassPathXmlApplicationContext("jlcindia.xml");
		System.out.println("Spring Container is ready");
		System.out.println("--------------------------------");
		Hello h=(Hello)ctx.getBean("hello");
		h.show();
		System.out.println("\n**** Second getBean() Call ****");
		h=(Hello)ctx.getBean("hello");
	}
}

/* In case of using Constructor and Setter Injection for two different fields in the same class,
 * (Like we did in Hello class), Spring container will run Constructor for Constructor Injection, 
 * and then Setter Injection will take place. This is because, an object will be required to invoke the setter method. 
 * 
 */